package cn.sieis.service.project;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.sieis.dao.ProjectMapper;
import cn.sieis.pojo.Project;

@Service
public class ProjectServiceImpl implements ProjectService {

	@Autowired
	private ProjectMapper projectMapper;

	@Override
	public List<Project> getProjectList(String queryProName, Integer queryProStatus, Integer queryProSchool,
			Integer queryProContest, Integer currentPageNo, Integer pageSize) throws Exception {
		// TODO Auto-generated method stub
		currentPageNo = (currentPageNo - 1) * pageSize;
		return projectMapper.getProjectList(queryProName, queryProStatus, queryProSchool, queryProContest,
				currentPageNo, pageSize);
	}

	@Override
	public int getProjectCount(String queryProName, Integer queryProStatus, Integer queryProSchool,
			Integer queryProContest) throws Exception {
		// TODO Auto-generated method stub
		return projectMapper.getProjectCount(queryProName, queryProStatus, queryProSchool, queryProContest);
	}

	@Override
	public boolean addProject(Project project) throws Exception {
		// TODO Auto-generated method stub
		boolean flag = false;
		if (projectMapper.addProject(project) > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean modify(Project project) throws Exception {
		// TODO Auto-generated method stub
		boolean flag = false;
		if (projectMapper.modify(project) > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public Project getProjectById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return projectMapper.getProjectById(id);
	}

	@Override
	public boolean deleteProjectById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		boolean flag = false;
		int i = projectMapper.deleteProjectById(id);
		if (i > 0) {
			flag = true;
		} else {
			flag = false;
		}
		return flag;
	}

	@Override
	public List<Project> getProList(String queryProName, Integer queryProStatus, Integer queryProSchool,
			Integer queryProContest) throws Exception {
		// TODO Auto-generated method stub
		return projectMapper.getProList(queryProName, queryProStatus, queryProSchool, queryProContest);
	}

	@Override
	public List<Project> getProProList() throws Exception {
		// TODO Auto-generated method stub
		return projectMapper.getProProList();
	}
	
	@Override
	public List<Project> getProjectListF(String proName, Integer proSchool) throws Exception {
		// TODO Auto-generated method stub
		return projectMapper.getProjectListF(proName, proSchool);
	}
	
		@Override
	public boolean sign(Project project) throws Exception {
			// TODO Auto-generated method stub
			boolean flag=false;
			if(projectMapper.sign(project)>0){
				flag=true;
			}		
			return flag;
		}

}
